In this demo you
will learn about navigational components
in the material library. Navigational components create
the navigational flow or a switch between different views based on user interaction. On the official material
design websites various navigational
components are defined, such as: Bottom Navigation, Breadcrumbs, Drawer, Tabs. Every navigation component has the functionality of switching
between different views. For example in Tabs, you can switch between different
views on a click action that renders different views
based on the tab name. Tab components are used
as rapper components with the onChange method that changes the views when the Tab
section is clicked. Tab views are defined into different tab panel
sections which finally get rendered on
clicking the different tabs. Moving to the code you have a Navbar.json file that has some material
components imported, such as: Tabs, Tab, AppBar, Toolbar, and Grid. To make the Navbar appear
on the top of the page, use the app component
with Toolbar. Tabs are components
responsible for implementing tab
view in material, Tabs accept two different
tabs; Home and Form. In the Tab section, there are various props called
handleChange that handle the user interaction
of changing between different tabs and render
the respective tab. Pass props such as: variant, textColor, and indicatorColor. Tabs generally
support such props. Now import the Navigation
bar in the app.js. You have to import
the Navbar from the Navigation bar
component in the code. In the Navbar component, the handleTab method is
passed as props that change the current tab state with the index value of
the selected tab. Also, the handleTab method renders the selected
tab from Tab panel. Now save the file and
execute the code. The Navbar section shows two
views in the application, Home View and Form View. Also, the UI changes based
on the user's click. This is how you can create
several navigations or different UIs using navigation
components. Thank you.